package com.ly.hotel.common;

import java.io.ByteArrayInputStream;
import java.util.HashMap;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import android.annotation.SuppressLint;
import android.util.Log;

public class SysConf {
	public static String SYS_CONF_RT_MSG_GET_INTERVAL = "rtmsg-interval";			//实时消息的获取时间间隔,ms级
	public static String SYS_CONF_CMD_GET_INTERVAL = "cmd-interval";				//推送命令的时间间隔,ms级
	public static String SYS_CONF_CALL_SYNC_INTERVAL = "call-sync-interval";		//同步呼叫状态
	public static String SYS_CONF_SHUAKA_TIPS_SHOW_TIME = "shuaka-show-time";		//同步呼叫状态
	public static String EXP_CONF_MONITOR_APP = "exp-monitor-app";					//扩展设备的app文件名
	public static String EXP_CONF_MONITOR_APP_CONF = "exp-monitor-app-conf";		//扩展设备的配置
	public static String SYS_CONF_AD_ENABLE = "cloud-ad-enable";					//云广告
	public static String SYS_CONF_INTERFACE_MODE = "interface-mode";				//接口模式0是网络，1是本地
	public static String SYS_CONF_CLOUD_URL = "cloud-url";							//云端网址
	public static String SYS_CONF_CLOUD_ENABLE = "cloud-enable";					//允许云端上网
	public static String SYS_CONF_CLOUD_LOGS_ENABLE = "cloud-logs-enable";			//云端日志
	public static String SYS_CONF_HTTP_PROXY = "http-proxy";						//http的代理服务器，用于云端上网
	public static String SYS_CONF_JISHI_URL = "jishi-url";							//指定的技师页面url,将会通过系统浏览器打开
	public static String SYS_CONF_XIAOFEI_URL = "xiaofei-url";						//指定的消费页面url,将会通过系统浏览器打开
	public static String SYS_CONF_ME_URL = "me-url";								//指定的"我"页面url,将会通过系统浏览器打开
	public static String SYS_CONF_ME_ENABLE = "me-enable";							//小圆点是否显示“我”按钮
	public static String SYS_CONF_SHOUPAI_ENABLE = "shoupai-enable";				//是否使用手牌
	public static String SYS_CONF_IPTV_PACKET_NAME = "iptv-packet-name";			//iptv的包名
	public static String SYS_CONF_IPMOVIE_PACKET_NAME = "ipmovie-packet-name";		//ipmovie的包名
	public static String SYS_CONF_GUESTCONTORL_PACKET_NAME = "guestcontrol-package-name";//客控系统apk的包名
	public static String SYS_CONF_IPMUSIC_PACKET_NAME = "ipmusic-packet-name";		//ipmovie的包名
	public static String SYS_CONF_HEARTRATE = "heart-rate";							//心跳包的速率
	public static String SYS_CONF_LOGO_ENABLE = "logo-enable";						//是否显示右上角logo
	public static String SYS_CONF_WEB_APP_INF_ENABLE = "webappinf-enable";			//运行webspa
	public static String SYS_CONF_CLOUD_APK_UPDATE_ENABLE = "cloud_apk_update-enable";//支持云端升级
	public static String SYS_CONF_USER_LOGIN_DIALOG = "user-login-dialog";			//开机登录界面
	public static String SYS_CONF_BL_ENABLE = "bl-enable";							//开启亮度功能
	public static String SYS_CONF_CO_BOARD_ENABLE = "co-board-enable";				//屏蔽协处理板
	public static String SYS_CONF_QR_CODE_TIPS = "qr-code-tips";					//二维码窗口提示语
	public static String SYS_CONF_FACTORY_DEBUG = "factory-debug";					//实施的调试模式
	public static String SYS_CONF_STARTUP_VOLUME = "volume";						//开机音量
	public static String SYS_CONF_SELF_HELP_BUTTON = "self-help-button";			//开启一个代替小圆点按钮的webspa
	public static String SYS_CONF_CHECK_NET_ENABLE = "check-net-enable";			//是否要判断以太网连接状态，0是禁止，1是运行
	public static String SYS_CONF_AD_QR_URL = "ad-qr-url";							//二维码广告链接
    public static String SYS_CONF_HOT_LINE = "hot-line";							//服务热线
	public static String SYS_CONF_QR_TIME = "qr-time";							    //二维码时间
	public static String SYS_CONF_STATEMENT = "state-ment";						    //是否弹出版权声明
	public static String HOTEL_VOD = "hotel_vod";								    //是否播放酒店视频
	public static String SYS_CONF_HOTELID = "hotel-id";							    //用户id，uvc用
	public static String SYS_CONF_SHOW_QR = "show-qr";							    //是否显示手机遥控
	public static String SYS_CONF_HEAD_DATA_SHOW = "head-data-show";                //是否显示多于的信息
	public static String SYS_CONF_AD_COUNT = "ad-count";                            //视频广告数量
	public static String SYS_CONF_AUTO_ENTER = "auto-enter";                        //自动进入主页面
	
	public static String expConf;
	public static String myMac;
	public static String myApp;
	/* 系统的扩展配置 */
	public static HashMap<String, String> extendConfMap = new HashMap<>();

	public static void extendConfPutValue(String key, String value) {
		if (extendConfMap != null) {
			extendConfMap.put(key, value);
		}
	}

	public static String extendConfGetValue(String key, String defaultValue) {
		if (extendConfMap != null && extendConfMap.get(key) != null) {
			return extendConfMap.get(key);
		} else {
			return defaultValue;
		}
	}

	public static String extendConfGetValue(String key) {
		if (extendConfMap != null && extendConfMap.get(key) != null) {
			return extendConfMap.get(key);
		}else{
			return null;
		}
	}
	
	public static void sysParse(String conf) throws Exception {
		Log.i("conf", "SysConf parse");
		if(conf == null){
			return;
		}
		Log.i("conf", conf);
		DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();
		DocumentBuilder dombuilder = domfac.newDocumentBuilder();
		Document doc = dombuilder.parse(new ByteArrayInputStream(conf.getBytes("utf-8")));
		// Element root=doc.getDocumentElement();

		NodeList sysList = doc.getElementsByTagName("rtmsg");
		if (sysList.getLength() == 1) {
			NodeList headList = ((Element) sysList.item(0)).getElementsByTagName("interval");
//			Log.i("conf", headList.getLength() + "");
			if (headList.getLength() == 1 && headList.item(0) != null) {
				// res.add(headList.item(i).getFirstChild().getNodeValue());
				extendConfPutValue(SYS_CONF_RT_MSG_GET_INTERVAL, headList.item(0).getFirstChild().getNodeValue());
				Log.i("conf",
						"extendConfGetValue:"
								+ SysConf.extendConfGetValue(SysConf.SYS_CONF_RT_MSG_GET_INTERVAL, "1000"));
			}
		}
 
		NodeList cmdList = doc.getElementsByTagName("cmd");
		if (cmdList.getLength() == 1 && ((Element) cmdList.item(0)) != null) {
			NodeList List2 = ((Element) cmdList.item(0)).getElementsByTagName("interval");
			if (List2.getLength() == 1) {
				extendConfPutValue(SYS_CONF_CMD_GET_INTERVAL, List2.item(0).getFirstChild().getNodeValue());
				Log.i("conf",
						"extendConfGetValueaaa:"
								+ SysConf.extendConfGetValue(SysConf.SYS_CONF_CMD_GET_INTERVAL, "1000"));
			}
		}

		NodeList adList = doc.getElementsByTagName("cloudAd");
		if (adList != null && adList.item(0) != null && adList.item(0).hasChildNodes()) {
			Log.i("conf", "cloudAd:" + adList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_AD_ENABLE, adList.item(0).getFirstChild().getNodeValue());
		}
		
		NodeList interList = doc.getElementsByTagName("interMode");
		if (interList != null && interList.item(0) != null && interList.item(0).hasChildNodes()) {
			Log.i("conf", "interMode:" + interList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_INTERFACE_MODE, interList.item(0).getFirstChild().getNodeValue());
		}
		
		extendConfPutValue(SYS_CONF_CLOUD_URL, Constants.DEFAULT_CLOUD_SERVER);
		
		NodeList cloudList = doc.getElementsByTagName("cloud");
		if (cloudList != null && cloudList.item(0) != null && cloudList.item(0).hasChildNodes()) {
			Log.i("conf", "cloud-enable:" + cloudList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_CLOUD_ENABLE, cloudList.item(0).getFirstChild().getNodeValue());
		}
		
		NodeList cloudLogsList = doc.getElementsByTagName("cloudLogs");
		if (cloudLogsList != null && cloudLogsList.item(0) != null && cloudLogsList.item(0).hasChildNodes()) {
			Log.i("conf", "cloud-logs-enable:" + cloudLogsList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_CLOUD_LOGS_ENABLE, cloudLogsList.item(0).getFirstChild().getNodeValue());
		}
		
		NodeList httpProxyList = doc.getElementsByTagName("httpProxy");
		if (httpProxyList != null && httpProxyList.item(0) != null && httpProxyList.item(0).hasChildNodes()) {
			Log.i("conf", "httpProxy:" + httpProxyList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_HTTP_PROXY, httpProxyList.item(0).getFirstChild().getNodeValue());
		}
		
		NodeList jishiList = doc.getElementsByTagName("jishiUrl");
		if (jishiList != null && jishiList.item(0) != null && jishiList.item(0).hasChildNodes()) {
			Log.i("conf", "jishiUrl:" + jishiList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_JISHI_URL, jishiList.item(0).getFirstChild().getNodeValue());
		}
		
		NodeList xiaofeoList = doc.getElementsByTagName("xiaofeiUrl");
		if (xiaofeoList != null && xiaofeoList.item(0) != null && xiaofeoList.item(0).hasChildNodes()) {
			Log.i("conf", "xiaofeiUrl:" + xiaofeoList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_XIAOFEI_URL, xiaofeoList.item(0).getFirstChild().getNodeValue());
		}
		
		NodeList shoupaiList = doc.getElementsByTagName("shouPai");
		if (shoupaiList != null && shoupaiList.item(0) != null && shoupaiList.item(0).hasChildNodes()) {
			Log.i("conf", "shouPai:" + shoupaiList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_SHOUPAI_ENABLE, shoupaiList.item(0).getFirstChild().getNodeValue());
		}
		 
		NodeList meEnableList = doc.getElementsByTagName("meButton");
		if (meEnableList != null && meEnableList.item(0) != null && meEnableList.item(0).hasChildNodes()) {
			Log.i("conf", "meButton:" + meEnableList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_ME_ENABLE, meEnableList.item(0).getFirstChild().getNodeValue());
		}	
		
		NodeList callList = doc.getElementsByTagName("callSyncInterval");
		if (callList != null && callList.item(0) != null && callList.item(0).hasChildNodes()) {
			Log.i("conf", "callSyncInterval:" + callList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_CALL_SYNC_INTERVAL, callList.item(0).getFirstChild().getNodeValue());
		}	
		
		NodeList shuakaList = doc.getElementsByTagName("shuaKaShowTime");
		if (shuakaList != null && shuakaList.item(0) != null && shuakaList.item(0).hasChildNodes()) {
			Log.i("conf", "shuaKaShowTime:" + shuakaList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_SHUAKA_TIPS_SHOW_TIME, shuakaList.item(0).getFirstChild().getNodeValue());
		}	
		
		NodeList iptvEnableList = doc.getElementsByTagName("ipTV");
		if (iptvEnableList != null && iptvEnableList.item(0) != null && iptvEnableList.item(0).hasChildNodes()) {
			Log.i("conf", "ipTV:" + iptvEnableList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_IPTV_PACKET_NAME, iptvEnableList.item(0).getFirstChild().getNodeValue());
		}else{
			extendConfPutValue(SYS_CONF_IPTV_PACKET_NAME, "");
		}

		NodeList ipmovieEnableList = doc.getElementsByTagName("moviePackage");
		if (ipmovieEnableList != null && ipmovieEnableList.item(0) != null && ipmovieEnableList.item(0).hasChildNodes()) {
			extendConfPutValue(SYS_CONF_IPMOVIE_PACKET_NAME, ipmovieEnableList.item(0).getFirstChild().getNodeValue());
		}else{
			extendConfPutValue(SYS_CONF_IPMOVIE_PACKET_NAME, "");
		}

		//第三方音乐包名
		NodeList ipmusicEnableList = doc.getElementsByTagName("musicPackage");
		if (ipmusicEnableList != null && ipmusicEnableList.item(0) != null && ipmusicEnableList.item(0).hasChildNodes()) {
			extendConfPutValue(SYS_CONF_IPMUSIC_PACKET_NAME, ipmusicEnableList.item(0).getFirstChild().getNodeValue());
		}else{
			extendConfPutValue(SYS_CONF_IPMUSIC_PACKET_NAME, "");
		}
		
		NodeList heartrateList = doc.getElementsByTagName("heartrate");
		if (heartrateList != null && heartrateList.item(0) != null && heartrateList.item(0).hasChildNodes()) {
			Log.i("conf", "heartrate:" + heartrateList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_HEARTRATE, heartrateList.item(0).getFirstChild().getNodeValue());
		}
		
		NodeList logoEnableList = doc.getElementsByTagName("logoEnable");
		if (logoEnableList != null && logoEnableList.item(0) != null && logoEnableList.item(0).hasChildNodes()) {
			Log.i("conf", "logoEnable:" + logoEnableList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_LOGO_ENABLE, logoEnableList.item(0).getFirstChild().getNodeValue());
		}else{
			extendConfPutValue(SYS_CONF_LOGO_ENABLE, "1");
		}
		
		NodeList webAppInfEnableList = doc.getElementsByTagName("webAppInfEnable");
		if (webAppInfEnableList != null && webAppInfEnableList.item(0) != null && webAppInfEnableList.item(0).hasChildNodes()) {
			Log.i("conf", "webAppInfEnable:" + webAppInfEnableList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_WEB_APP_INF_ENABLE, webAppInfEnableList.item(0).getFirstChild().getNodeValue());
		}
		
		NodeList cloudApkUpdateEnableList = doc.getElementsByTagName("cloudApkUpdateEnable");
		if (cloudApkUpdateEnableList != null && cloudApkUpdateEnableList.item(0) != null && cloudApkUpdateEnableList.item(0).hasChildNodes()) {
			Log.i("conf", "cloudApkUpdateEnable:" + cloudApkUpdateEnableList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_CLOUD_APK_UPDATE_ENABLE, cloudApkUpdateEnableList.item(0).getFirstChild().getNodeValue());
		}	
		
		NodeList userLoginEnableList = doc.getElementsByTagName("userLoginEnable");
		if (userLoginEnableList != null && userLoginEnableList.item(0) != null && userLoginEnableList.item(0).hasChildNodes()) {
			Log.i("conf", "userLoginEnable:" + userLoginEnableList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_USER_LOGIN_DIALOG, userLoginEnableList.item(0).getFirstChild().getNodeValue());
		}
		
		NodeList blEnableList = doc.getElementsByTagName("blEnable");
		if (blEnableList != null && blEnableList.item(0) != null && blEnableList.item(0).hasChildNodes()) {
			Log.i("conf", "blEnable:" + blEnableList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_BL_ENABLE, blEnableList.item(0).getFirstChild().getNodeValue());
		}
		
		NodeList coBoardEnableList = doc.getElementsByTagName("coBoardEnable");
		if (coBoardEnableList != null && coBoardEnableList.item(0) != null && coBoardEnableList.item(0).hasChildNodes()) {
			Log.i("conf", "coBoardEnable:" + coBoardEnableList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_CO_BOARD_ENABLE, coBoardEnableList.item(0).getFirstChild().getNodeValue());
		}
		
		NodeList qrCodeTipsEnableList = doc.getElementsByTagName("qrCodeTips");
		if (qrCodeTipsEnableList != null && qrCodeTipsEnableList.item(0) != null && qrCodeTipsEnableList.item(0).hasChildNodes()) {
			Log.i("conf", "qrCodeTips:" + qrCodeTipsEnableList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_QR_CODE_TIPS, qrCodeTipsEnableList.item(0).getFirstChild().getNodeValue());
		}		
		
		NodeList factoryDebugList = doc.getElementsByTagName("factoryDebug");
		if (factoryDebugList != null && factoryDebugList.item(0) != null && factoryDebugList.item(0).hasChildNodes()) {
			Log.i("conf", "factoryDebug:" + factoryDebugList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_FACTORY_DEBUG, factoryDebugList.item(0).getFirstChild().getNodeValue());
		}		
		
		NodeList volumeList = doc.getElementsByTagName("volume");
		if (volumeList != null && volumeList.item(0) != null && volumeList.item(0).hasChildNodes()) {
			Log.i("conf", "volumeList:" + volumeList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_STARTUP_VOLUME, volumeList.item(0).getFirstChild().getNodeValue());
		}	
		
		NodeList selfHelpButtonList = doc.getElementsByTagName("selfHelpButton");
		if (selfHelpButtonList != null && selfHelpButtonList.item(0) != null && selfHelpButtonList.item(0).hasChildNodes()) {
			Log.i("conf", "selfHelpButtonListList:" + selfHelpButtonList.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_SELF_HELP_BUTTON, selfHelpButtonList.item(0).getFirstChild().getNodeValue());
		}			
		
		NodeList adQRurl = doc.getElementsByTagName("adQrurl");
		if (adQRurl != null && adQRurl.item(0) != null && adQRurl.item(0).hasChildNodes()) {
			Log.i("conf", "adQRurl:" + adQRurl.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_AD_QR_URL, adQRurl.item(0).getFirstChild().getNodeValue());
		}

		//服务热线，默认普瑞尔4008-352-888
        NodeList hotLine = doc.getElementsByTagName("hotLine");
        if (hotLine != null && hotLine.item(0) != null && hotLine.item(0).hasChildNodes()) {
            Log.i("conf", "adQRurl:" + hotLine.item(0).getFirstChild().getNodeValue());
            extendConfPutValue(SYS_CONF_HOT_LINE, hotLine.item(0).getFirstChild().getNodeValue());
        }else{
            extendConfPutValue(SYS_CONF_HOT_LINE, "4008-352-888");
        }

		//二维码页面显示时间
		NodeList qrHideTime = doc.getElementsByTagName("qrHideTime");
		if (qrHideTime != null && qrHideTime.item(0) != null && qrHideTime.item(0).hasChildNodes()) {
			Log.i("conf", "qrHideTime:" + qrHideTime.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_QR_TIME, qrHideTime.item(0).getFirstChild().getNodeValue());
		}

		//版权声明
		NodeList statement = doc.getElementsByTagName("statement");
		if (statement != null && statement.item(0) != null && statement.item(0).hasChildNodes()) {
			Log.i("conf", "statement:" + statement.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_STATEMENT, statement.item(0).getFirstChild().getNodeValue());
		}

		//酒店广告
		NodeList hotelVod = doc.getElementsByTagName("hotelVod");
		if (hotelVod != null && hotelVod.item(0) != null && hotelVod.item(0).hasChildNodes()) {
			Log.i("conf", "hotelVod:" + hotelVod.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(HOTEL_VOD, hotelVod.item(0).getFirstChild().getNodeValue());
		}

		//默认消息
		NodeList defaultMessage = doc.getElementsByTagName("defaultMessage");
		if (defaultMessage != null && defaultMessage.item(0) != null && defaultMessage.item(0).hasChildNodes()) {
			Log.i("conf", "defaultMessage:" + defaultMessage.item(0).getFirstChild().getNodeValue());
			SharedPreferencesConfig.setDefaultMessage(MyApplication.getContext(),defaultMessage.item(0).getFirstChild().getNodeValue());
		}else {
			SharedPreferencesConfig.setDefaultMessage(MyApplication.getContext(),"");
		}

		NodeList bottomText = doc.getElementsByTagName("bottomText");
		if (bottomText != null && bottomText.item(0) != null && bottomText.item(0).hasChildNodes()) {
			Log.i("conf", "bottomText:" + bottomText.item(0).getFirstChild().getNodeValue());
			SharedPreferencesConfig.setBottomText(MyApplication.getContext(),bottomText.item(0).getFirstChild().getNodeValue());
		}else{
			SharedPreferencesConfig.setBottomText(MyApplication.getContext(),"");
		}

		NodeList hotelId = doc.getElementsByTagName("hotelId");
		if (hotelId != null && hotelId.item(0) != null && hotelId.item(0).hasChildNodes()) {
			Log.i("conf", "hotelId:" + hotelId.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_HOTELID, hotelId.item(0).getFirstChild().getNodeValue());
		}

		NodeList qrRemote = doc.getElementsByTagName("qrRemote");
		if (qrRemote != null && qrRemote.item(0) != null && qrRemote.item(0).hasChildNodes()) {
			Log.i("conf", "qrRemote:" + qrRemote.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_SHOW_QR, qrRemote.item(0).getFirstChild().getNodeValue());
		}

		//酒店客控系统apk包名
		NodeList guestControlPackage = doc.getElementsByTagName("guestControlPackage");
		if (guestControlPackage != null && guestControlPackage.item(0) != null && guestControlPackage.item(0).hasChildNodes()){
			Log.i("conf", "guestControlPackage:" + guestControlPackage.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_GUESTCONTORL_PACKET_NAME,guestControlPackage.item(0).getFirstChild().getNodeValue());
		}else {
			extendConfPutValue(SYS_CONF_GUESTCONTORL_PACKET_NAME,"");
		}

		NodeList headDataShow = doc.getElementsByTagName("headDataShow");
		if (headDataShow != null && headDataShow.item(0) != null && headDataShow.item(0).hasChildNodes()) {
			Log.i("conf", "headDataShow:" + headDataShow.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_HEAD_DATA_SHOW, headDataShow.item(0).getFirstChild().getNodeValue());
		}

		NodeList adCount = doc.getElementsByTagName("adCount");
		if (adCount != null && adCount.item(0) != null && adCount.item(0).hasChildNodes()) {
			Log.i("conf", "adCount:" + adCount.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_AD_COUNT, adCount.item(0).getFirstChild().getNodeValue());
		}

		NodeList autoEnter = doc.getElementsByTagName("autoEnter");
		if (autoEnter != null && autoEnter.item(0) != null && autoEnter.item(0).hasChildNodes()) {
			Log.i("conf", "autoEnter:" + autoEnter.item(0).getFirstChild().getNodeValue());
			extendConfPutValue(SYS_CONF_AUTO_ENTER, autoEnter.item(0).getFirstChild().getNodeValue());
		}

	}
	
	@SuppressLint("DefaultLocale")
	public static void expParse(String conf) throws Exception {
		Log.i("conf", "ExpConf parse:" + conf);
		if(conf == null || conf.equals("")){
			return;
		}
		
		DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();
		DocumentBuilder dombuilder = domfac.newDocumentBuilder();
		Document doc = dombuilder.parse(new ByteArrayInputStream(conf.getBytes("utf-8")));
		// Element root=doc.getDocumentElement();

		NodeList list = doc.getElementsByTagName("exp");
		NodeList subList;
		for(int i=0;i<list.getLength();i++) {
			Log.i("conf", "我的MAC," + MyApplication.getMAC());
			subList = ((Element) list.item(i)).getElementsByTagName("mac");
			String mac = subList.item(0).getFirstChild().getNodeValue();
			subList = ((Element) list.item(i)).getElementsByTagName("app");
			String app = subList.item(0).getFirstChild().getNodeValue();
			subList = ((Element) list.item(i)).getElementsByTagName("conf");
			String conf1 = subList.item(0).getFirstChild().getNodeValue();
			
			Log.i("conf", mac);
			Log.i("conf", app);
			Log.i("conf", conf1);
			 
			//找到自己的配置了
			Log.i("conf", "我的MAC," + MyApplication.getMAC().toLowerCase()+ "-" + mac.toLowerCase());
			if(MyApplication.getMAC().toLowerCase().equals(mac.toLowerCase())){
				Log.i("conf", "根据配置重新设置:" + conf1);
//				保存对应的配置，给接口用
				expConf = conf1;
				myMac = mac;
				myApp = app;
				extendConfPutValue(EXP_CONF_MONITOR_APP, app);
				extendConfPutValue(EXP_CONF_MONITOR_APP_CONF, conf1);
			}
			
		}
	}
}
